package com.ruoyi.blog.util;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;

public class A {
    private static final String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCs9GexPgr+WVLXEmXQr25qxrM/psKXth+W9r5p58Egx0fVMtumcjiMIzkscjk2tafzGMx72E9Cc7uxblBInnDF+TR4MAQGlNZsXzA5rl5mePZvClMdXx5fSAKKbHNIXqlcCYscgXr0+jTcOyD25lxketLhRn/wXVmk06MqQGbSwIDAQAB";
    private static final String PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMKz0Z7E+Cv5ZUtcSZdCvbmrGsz+mwpe2H5b2vmnnwSDHR9Uy26ZyOIwjOSxyOTa1p/MYzHvYT0Jzu7FuUEiecMX5NHgwBAaU1mxfMDmuXmZ49m8KUx1fHl9IAopsc0heqVwJixyBevT6NNw7IPbmXGR60uFGf/BdWaTToypAZtLAgMBAAECgYAfhWEgZR8Qb3XYt34qgOGaV3slSOrsyOIfwts2o854uolSczXkF/2PsPB+bdHqSwuIH1zHzstdSGM6AMS3KM+xX5+tgRXPRdBHyUIU7OZInbLAi8t5sX+xOHVK5Gmo7+A3CY/Woq4Wrolopq7BAHR/vU8nSuBGTxIOfrWd2cQtMQJBAOs9kOEIyPb4kHi2zoai3WQ6lIm6rXIHFdcBistiJ9k2zyMgSF+31M1mLvGeK9PNdQHwWZqhgPKgV1REoxyMXt8CQQDT4m/vFYOQbL8+bCMji7Ea5OjF2tMCpywmhFWJiRYd6pbNBqiCuZJ/lVZeN24BlXPCoL1Eeq/BdNjLae3PY40VAkBGjN1RkDftUdjKS1EfMeMh9yurLtBr3VIgfHbqzlJTI8v1pe3uvwxUWawEjMJqMDlCTpog9QTeP1ZRkJA2tKaTAkA5ueRjD8pzS51i5VVBdup+eEUOuopom6EEsWMYgHe9GM+S9jBsxSArkEUikBlxZwVNzjsicAZ4P1xdNvPqX6XtAkACwc2RyaZeGly26aOvAKurg1z+HW8FP6m8jXTpuahRc0dBjBO4Xyd7dYkRQinaRYRXrzY+drtPi+NxLJiY7jS0";
    public static void main(String[] args) {
        RSA rsa = new RSA(PRIVATE_KEY, PUBLIC_KEY);

        byte[] encrypt = rsa.encrypt(StrUtil.str("你好呀你好呀",CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
        byte[] decrypt = rsa.decrypt(encrypt, KeyType.PrivateKey);
        // 生成的密码
        System.out.println(StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));

    }
}
